<?xml version='1.0' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>IGNORED</title>
    </h:head>
    <h:body>
        <ui:composition template="/template/tmp.xhtml">
            <ui:define name="left">
                <ui:include src="/calcs/left.xhtml"/>
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <h:panelGrid columns="3" style="color: white">
                        <f:facet name="header">
                            <h:outputText value="Inputs"/>
                        </f:facet>
                        <h:column>
                            <h:outputText value="Start volume: "/>
                        </h:column>
                        <h:column>
                            <h:inputText id="op" value="#{calc.startvol}" required="true" requiredMessage="Ingen verdi!" validatorMessage="Kun 0 - 1000liter!" validator="#{calc.validerTall(context, component, value)}">
                                <f:validateDoubleRange minimum="0.0" maximum="1000.0"/>
                                <f:ajax event="keyup" execute="@this" render="startvolO"/>
                                <f:ajax event="keyup" execute="@this" render="totvolO"/>
                                <f:ajax event="keyup" execute="@this" render="fsgO"/>
                                <f:ajax event="keyup" execute="@this" render="startM"/>
                            </h:inputText>
                        </h:column>
                        <h:column>
                            <h:message id="startM" for="op"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="SG: "/>
                        </h:column>
                        <h:column>
                            <h:inputText id="sg" value="#{calc.sg}" required="true" requiredMessage="Ingen verdi!" validatorMessage="Kun 1,000-1,200!">
                                <f:convertNumber pattern="#.000"/>
                                <f:validateDoubleRange maximum="1.200" minimum="1.000"/>
                                <f:ajax event="keyup" execute="@this" render="sgO"/>
                                <f:ajax event="keyup" execute="@this" render="fsgO"/>
                                <f:ajax event="keyup" execute="@this" render="sgM"/>
                            </h:inputText>
                        </h:column>
                        <h:column>
                            <h:message id="sgM" for="sg"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="Vann lagt til: "/>
                        </h:column>
                        <h:column>
                            <h:inputText id="vann" value="#{calc.vann}" required="true" requiredMessage="Ingen verdi!" validatorMessage="Kun 0 - 1000liter!">
                                <f:validateDoubleRange minimum="0.0" maximum="1000.0"/>
                                <f:ajax event="keyup" execute="@this" render="vannO"/>
                                <f:ajax event="keyup" execute="@this" render="fsgO"/>
                                <f:ajax event="keyup" execute="@this" render="totvolO"/>
                                <f:ajax event="keyup" execute="@this" render="vannM"/>
                            </h:inputText>
                        </h:column>
                        <h:column>
                            <h:message id="vannM" for="vann"/>
                        </h:column>
                    </h:panelGrid>

                    <br/>

                    <h:panelGrid columns="2" style="color: white" id="pg2">
                        <f:facet name="header">
                            <h:outputText value="Outputs"/>
                        </f:facet>
                        <h:column>
                            <h:outputText value="Startvolume"/>
                        </h:column>
                        <h:column>
                            <h:outputText id="startvolO" value="#{calc.startvol}">
                                <f:convertNumber pattern="#.##"/>
                            </h:outputText>
                            <h:outputText value=" liter"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="SG:"/>
                        </h:column>
                        <h:column>
                            <h:outputText id="sgO" value="#{calc.sgformatted}"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="Vann lagt til"/>
                        </h:column>
                        <h:column>
                            <h:outputText id="vannO" value="#{calc.vann}"/>
                            <h:outputText value=" liter"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="Total volume: "/>
                        </h:column>
                        <h:column>
                            <h:outputText id="totvolO" value="#{calc.totVol()}">
                                <f:convertNumber pattern="#.##"/>
                            </h:outputText>
                            <h:outputText value=" liter"/>
                        </h:column>
                        <h:column>
                            <h:outputText value="Final SG: "/>
                        </h:column>
                        <h:column>
                            <h:outputText id="fsgO" value="#{calc.beregnDil()}"/>
                        </h:column>
                    </h:panelGrid>
                    <h:messages/>
                    <br/>
                    <h:commandButton value="Reset"/>
                    <h:commandButton value="Tilbake" action="/index?faces-redirect=true"/>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>